<!--
 * @FilePath: /vue3-demo/src/components/AsyncComponent.vue
 * @Author: Yongchao Wang
 * @Date: 2020-09-21 17:33:19
 * @LastEditors: Yongchao Wang
 * @LastEditTime: 2020-09-21 17:40:56
-->
<template>
  <h1>this is async component</h1>
</template>

<script>
const sleep = (time) => {
  return new Promise((reslove, reject) => {
    setTimeout(() => {
      reslove();
    }, time);
  });
};

export default {
  name: "AsyncComponent",
  async setup() {
    // ... some code 将初始化页面需要的数据放在此处，
    await sleep(3000); //模拟数据请求
  },
};
</script>
